package com.core.website.scheduled;

import com.core.website.mapper.AccessMapper;
import com.core.website.util.SpringUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class AccessScheduleTask {

    private AccessMapper accessMapper;
    @Scheduled(cron = "0 0 0 * * ?")
    public void configureTasks() {
        if(null==accessMapper){
            accessMapper=SpringUtil.getBean(AccessMapper.class);
        }
        int dayNum = accessMapper.queryDayAccess();
        int totalNum = accessMapper.queryTotalAccess();
        accessMapper.clearDayAccess();
        accessMapper.updateTotalAccess(totalNum+dayNum);
    }
}